﻿using System;
using System.Linq;
using Wicresoft.RDW.Presentation;
using Wicresoft.RDW.Utility;

namespace Wicresoft.RDW.Request
{
    public partial class RentApply : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Save(RequestStatus.Pending);
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Save(RequestStatus.Draft);
        }
        protected void Save(RequestStatus status)
        {
            Model.Request request = RequestBasic.RequestData;
            request.Status = (int)status;
            request.RentRequest.Add(RentRequest.RentRequestData);
            if (request.RequestId > 0)
            {
                RequestPresent.Update(request);
            }
            else
            {
                RequestPresent.Create(request);
            }
        }
    }
}